#include "entCube.h"

#include <assert.h>

#include "types.h"

//--------------------------------------------------------------------------------------------------

EntCube::EntCube()
{
	colour.r = 255.0f;
	colour.g = 255.0f;
	colour.b = 255.0f;

	type = ENT_TYPE_CUBE;
}

EntCube::EntCube(ofxXmlSettings &xml) : Entity(xml)
{
	// Load colour values
	colour.r = xml.getValue("colour:r", 255.0f);
	colour.g = xml.getValue("colour:g", 255.0f);
	colour.b = xml.getValue("colour:b", 255.0f);

	type = ENT_TYPE_CUBE;
}

void EntCube::customDraw()
{
	ofSetColor(colour);
	ofBox(1);
}

void EntCube::save(ofxXmlSettings &xml)
{
	// Standard attribute save ** IMPORTANT
	Entity::save(xml);

	xml.setValue("colour:r", colour.r);
	xml.setValue("colour:g", colour.g);
	xml.setValue("colour:b", colour.b);
}

Entity* EntCube::copy()
{
	EntCube* newCube = new EntCube();

	entityStandardAttributesCopy(newCube, this);

	newCube->colour = this->colour;

	return newCube;
}

//--------------------------------------------------------------------------------------------------

Entity* entCube_create(ofxXmlSettings &xml)
{
	return new EntCube(xml);
}

//--------------------------------------------------------------------------------------------------
